<?php
/**
 * Created by PhpStorm.
 * User: 11509
 * Date: 2021/3/24
 * Time: 13:47
 */

namespace app\admin\model;


use think\facade\Db;
use think\Model;

class Gbrand extends Model
{

    protected $table = 'ecm_brand';
    protected $pk = 'brand_id';

    public static function getBrandSel($where,$whereOr)
    {
                $where[] = function ($query) use ($whereOr){
            $query->whereOr($whereOr);
        };

        $sel=Gbrand::where($where)
            ->order('sort_order','asc')
            ->paginate(['list_rows'=>10,'query'=>request()->param()]);

        return $sel;
    }

    public static function addBrandInfo($data)
    {
        try{
            $res = Gbrand::strict(true)->save($data);
            $msg = '添加成功';
        }catch(\Exception $e){
            $res = false;
            $msg = $e->getMessage();
        }
        return [$res,$msg];
    }

    public static function brandEdit($param)
    {
        try{
            $res=Gbrand::find($param['brand_id'])->save($param);
            $msg='修改成功';
        }catch(\Exception $e){
            $res=false;
            $msg=$e->getMessage();
        }
        return [$res,$msg];
    }

}